//
//  NavigationRootViewController.m
//  JinYong_iOS_Store
//
//  Created by 王厚一 on 2017/10/17.
//  Copyright © 2017年 why. All rights reserved.
//

#import "NavigationRootViewController.h"

@interface NavigationRootViewController () <UINavigationControllerDelegate, UIGestureRecognizerDelegate>

@end

@implementation NavigationRootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.navigationBar.hidden = YES;
    //取得原有target和action
    id target = self.interactivePopGestureRecognizer.delegate;
    SEL handler = NSSelectorFromString(@"handleNavigationTransition:");
    //新手势的范围整个view大小
    UIView *targetView = self.interactivePopGestureRecognizer.view;
    //添加新的手势
    UIPanGestureRecognizer * fullScreenGes = [[UIPanGestureRecognizer alloc]initWithTarget:target action:handler];
    fullScreenGes.delegate = self;
    [targetView addGestureRecognizer:fullScreenGes];
    //关闭原有侧滑方法
    [self.interactivePopGestureRecognizer setEnabled:NO];
}

- (BOOL)gestureRecognizerShouldBegin:(UIPanGestureRecognizer *)gestureRecognizer {
    //解决与左滑手势冲突
    CGPoint translation = [gestureRecognizer translationInView:gestureRecognizer.view];
    if (translation.x <= 0) {
        return NO;
    }
    BOOL isnav = self.childViewControllers.count == 1 ? NO : YES;
    return isnav;
}

@end
